%%{init: {'themeVariables': { 'fontSize': '12px'}}}%%
graph TD
    classDef path fill:#eee,stroke:#000,color:#000
    classDef plan fill:#fff,stroke-width:1px,color:#000
    classDef itemplan fill:#fff,stroke-width:2px,color:#000
    classDef unbatchedplan fill:#dff,stroke-width:1px,color:#000
    classDef sideeffectplan fill:#fcc,stroke-width:2px,color:#000
    classDef bucket fill:#f6f6f6,color:#000,stroke-width:2px,text-align:left

    subgraph "Buckets for queries/conditions/complex-filter"
    Bucket0("Bucket 0 (root)<br /><br />1: <br />ᐳ: 6, 14, 15, 45, 46, 47, 11, 16, 18, 25, 35, 10, 24, 31, 9, 8, 19<br />2: PgSelectInlineApply[41]<br />3: PgSelect[13]<br />ᐳ: Access[42]<br />4: PgSelectRows[20]"):::bucket
    Bucket1("Bucket 1 (listItem)<br />Deps: 42<br /><br />ROOT __Item{1}ᐸ20ᐳ[21]"):::bucket
    Bucket2("Bucket 2 (nullableBoundary)<br />Deps: 22, 42, 21<br /><br />ROOT PgSelectSingle{1}ᐸforumsᐳ[22]<br />1: <br />ᐳ: 23, 43, 44<br />2: PgSelectRows[36]"):::bucket
    Bucket3("Bucket 3 (listItem)<br /><br />ROOT __Item{3}ᐸ36ᐳ[37]"):::bucket
    Bucket4("Bucket 4 (nullableBoundary)<br />Deps: 38<br /><br />ROOT PgSelectSingle{3}ᐸmessagesᐳ[38]"):::bucket
    end
    Bucket0 --> Bucket1
    Bucket1 --> Bucket2
    Bucket2 --> Bucket3
    Bucket3 --> Bucket4

    %% plan dependencies
    PgSelect13[["PgSelect[13∈0] ➊<br />ᐸforumsᐳ"]]:::plan
    Object16{{"Object[16∈0] ➊<br />ᐸ{pgSettings,withPgClient}ᐳ"}}:::plan
    Lambda18{{"Lambda[18∈0] ➊<br />ᐸincludeArchivedConditionᐳ<br />More deps:<br />- Constantᐸ[ undefined, 'INHERIT' ]ᐳ[45]"}}:::plan
    ApplyInput19{{"ApplyInput[19∈0] ➊"}}:::plan
    PgSelectInlineApply41["PgSelectInlineApply[41∈0] ➊"]:::plan
    Object16 & Lambda18 & ApplyInput19 & PgSelectInlineApply41 --> PgSelect13
    __InputObject10{{"__InputObject[10∈0] ➊<br />More deps:<br />- Constantᐸundefinedᐳ[6]"}}:::plan
    __InputObject11{{"__InputObject[11∈0] ➊<br />More deps:<br />- Constantᐸtrueᐳ[47]<br />- Constantᐸundefinedᐳ[6]"}}:::plan
    __InputObject11 --> __InputObject10
    Access14{{"Access[14∈0] ➊<br />ᐸ2.pgSettingsᐳ"}}:::plan
    Access15{{"Access[15∈0] ➊<br />ᐸ2.withPgClientᐳ"}}:::plan
    Access14 & Access15 --> Object16
    __InputObject24{{"__InputObject[24∈0] ➊<br />More deps:<br />- Constantᐸundefinedᐳ[6]"}}:::plan
    __InputObject25{{"__InputObject[25∈0] ➊<br />More deps:<br />- Constantᐸundefinedᐳ[6]<br />- Constantᐸtrueᐳ[47]"}}:::plan
    __InputObject25 --> __InputObject24
    ApplyInput31{{"ApplyInput[31∈0] ➊"}}:::plan
    Lambda35{{"Lambda[35∈0] ➊<br />ᐸincludeArchivedConditionᐳ<br />More deps:<br />- Constantᐸ[HIDDEN]ᐳ[46]"}}:::plan
    ApplyInput31 & Lambda35 --> PgSelectInlineApply41
    __InputObject8{{"__InputObject[8∈0] ➊"}}:::plan
    __InputObject9{{"__InputObject[9∈0] ➊"}}:::plan
    __InputObject9 --> __InputObject8
    __InputObject10 --> __InputObject9
    __Value2["__Value[2∈0] ➊<br />ᐸcontextᐳ"]:::plan
    __Value2 --> Access14
    __Value2 --> Access15
    __InputObject8 --> ApplyInput19
    PgSelectRows20[["PgSelectRows[20∈0] ➊"]]:::plan
    PgSelect13 --> PgSelectRows20
    __InputObject24 --> ApplyInput31
    Access42{{"Access[42∈0] ➊<br />ᐸ13.m.subqueryDetailsFor27ᐳ"}}:::plan
    PgSelect13 --> Access42
    __Item21[/"__Item[21∈1]<br />ᐸ20ᐳ"\]:::itemplan
    PgSelectRows20 ==> __Item21
    PgSelectSingle22{{"PgSelectSingle[22∈1]<br />ᐸforumsᐳ"}}:::plan
    __Item21 --> PgSelectSingle22
    List43{{"List[43∈2]<br />ᐸ42,21ᐳ"}}:::plan
    Access42 & __Item21 --> List43
    PgClassExpression23{{"PgClassExpression[23∈2]<br />ᐸ__forums__.”name”ᐳ"}}:::plan
    PgSelectSingle22 --> PgClassExpression23
    PgSelectRows36[["PgSelectRows[36∈2]"]]:::plan
    Lambda44{{"Lambda[44∈2]<br />ᐸpgInlineViaSubqueryTransformᐳ"}}:::plan
    Lambda44 --> PgSelectRows36
    List43 --> Lambda44
    __Item37[/"__Item[37∈3]<br />ᐸ36ᐳ"\]:::itemplan
    PgSelectRows36 ==> __Item37
    PgSelectSingle38{{"PgSelectSingle[38∈3]<br />ᐸmessagesᐳ"}}:::plan
    __Item37 --> PgSelectSingle38
    PgClassExpression39{{"PgClassExpression[39∈4]<br />ᐸ__messages__.”body”ᐳ"}}:::plan
    PgSelectSingle38 --> PgClassExpression39
    PgClassExpression40{{"PgClassExpression[40∈4]<br />ᐸ__messages__.”featured”ᐳ"}}:::plan
    PgClassExpression39 o--o PgClassExpression40

    %% define steps
    classDef bucket0 stroke:#696969
    class Bucket0,__Value2,__InputObject8,__InputObject9,__InputObject10,__InputObject11,PgSelect13,Access14,Access15,Object16,Lambda18,ApplyInput19,PgSelectRows20,__InputObject24,__InputObject25,ApplyInput31,Lambda35,PgSelectInlineApply41,Access42 bucket0
    classDef bucket1 stroke:#00bfff
    class Bucket1,__Item21,PgSelectSingle22 bucket1
    classDef bucket2 stroke:#7f007f
    class Bucket2,PgClassExpression23,PgSelectRows36,List43,Lambda44 bucket2
    classDef bucket3 stroke:#ffa500
    class Bucket3,__Item37,PgSelectSingle38 bucket3
    classDef bucket4 stroke:#0000ff
    class Bucket4,PgClassExpression39,PgClassExpression40 bucket4

